package cn.lycode.common.enums;

import cn.lycode.common.exception.ServiceExceptionCustomAssert;

/**
 * 六位数字
 * 9开头表示错误  后面两位是模块
 * 3开头表示后端服务限制原因报错
 * 4开头表示客户输入异常报错
 * 5表示后端服务异常行为报错
 */
public enum ErrorEnum implements ServiceExceptionCustomAssert {

    SUCCESS("000000", "成功"),
    FAILED("999999", "失败"),

    /**
     * 权限相关
     */
    PARAMS_VALID_ERROR("900310", "参数校验错误"),
    PARAMS_TYPE_ERROR("900311", "参数类型错误"),
    REQUEST_METHOD_ERROR("900312", "请求方法错误"),
    ASSERT_ARGUMENT_ERROR("900313", "断言参数错误"),
    ASSERT_MYBATIS_ERROR("900314", "断言Mybatis错误"),
    BAD_USERNAME_OR_PASSWORD("900330", "登录账号或密码错误"),
    LOGIN_DISABLE_ERROR("900331", "登录账号已被禁用了"),
    TOKEN_EMPTY("900332", "token参数为空"),
    TOKEN_INVALID("900333", "token参数无效"),
    USER_INVALID("900334", "无效用户"),

    CAPTCHA_ERROR("900335", "验证码错误"),
    PAYMENT_ERROR("900336", "发起支付失败"),


    NO_PERMISSION("900403", "无相关权限"),
    REQUEST_404_ERROR("900404", "请求接口不存在"),
    BAD_METHOD("900405", "不支持的请求方式"),
    BAD_REQUEST("900406", "请求路径中缺少必需的路径变量"),


    /**
     * 业务相关
     */
    INVALID_ID("900340", "无效ID"),
    PARAM_NULL("900341", "参数为NULL"),
    PARAM_EMPTY("900342", "参数为空"),
    NOT_EXISTS("900343", "不存在"),
    EXISTS("900344", "已存在"),
    DEPT_LOCKED("900345", "部门锁定，不允许新增"),
    EXIST_DICT("900346", "禁止插入重复字典！"),
    PARAM_ERROR("900341", "参数错误！"),
    FORBID_OPERATION("900342", "禁止操作！"),
    EXIST_USERNAME("900344", "此用户名已存在！"),

    SYSTEM_ERROR("900500", "系统错误");

    /**
     * 构造方法
     */
    private  String code;
    private  String msg;
    ErrorEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public ErrorEnum message(String code, String message) {
        this.code = code;
        this.msg = message;
        return this;
    }
    public ErrorEnum message(String message) {
        this.msg = message;
        return this;
    }

    /**
     * 获取状态码
     *
     * @author fzr
     * @return Long
     */
    public String getCode() {
        return this.code;
    }


    /**
     * 获取提示
     *
     * @author fzr
     * @return String
     */
    public String getMsg() {
        return this.msg;
    }



}
